<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="课题管理">
<body class="input">
<script type="text/javascript" charset="utf-8" src="${web_static}/kindeditor/kindeditor.js"></script>
<script type="text/javascript" charset="utf-8" src="${web_static}/kindeditor/lang/zh_CN.js"></script>
<script>
	$().ready( function() {
	
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		var $validateForm = $("#inputForm");
		var $tab = $("#tab");
	
		// Tab效果
		$tab.tabs(".tabContent", {
			tabs: "input"
		});
		
		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			rules: {
				"topicInfo.topicName": {
						required: true,
						maxlength:50
				},
				"topicInfo.videoPath": {
						url: true
				},
				"topicInfo.topicBeginTimeStart": {
						required: true
				},
				"topicInfo.topicEndTimeEnd": {
						required: true
				},
				"topicInfo.topicIntroduction":{
						maxlength:200
				}
			},
			messages: {
				"topicInfo.topicName": {
						required: "请输入课题名称",
						maxlength: "课题名称必须在50个字符以内"
				},
				"topicInfo.videoPath": {
						url: "请输入合法的视频地址"
				} ,
				"topicInfo.topicBeginTimeStart": {
						required: "请选择课题开始日期"
				} ,
				"topicInfo.topicEndTimeEnd": {
						required: "请选择课题结束日期"
				} ,
				"topicInfo.topicIntroduction":{
						maxlength:"课题简介必须在200个字符内"
				}
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		});
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list actionErrors as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
	});
	
	function showDiv(picId,imgdiv,imgShow){
   		new uploadPreview({ UpBtn: picId, DivShow: imgdiv, ImgShow: imgShow });
	}
	
	function clearImg(imgId,imgShow){
		var obj = document.getElementById(imgId) ;   
		obj.outerHTML=obj.outerHTML;  
		
		$('#'+imgShow).attr("src", "");
	}

KindEditor.ready(function(K) {
	var editor1 = K.create('textarea[name="content"]', {
		cssPath : '${web_static}/kindeditor/plugins/code/prettify.css',
		uploadJson : '${web_base}/go/topic!imgUpload.htm',
		fileManagerJson : '${web_base}/go/topic!fileManager.htm',
		allowFileManager : true,
		afterCreate : function() {
			var self = this;
			K.ctrl(document, 13, function() {
				self.sync();
				document.forms['inputForm'].submit();
			});
			K.ctrl(self.edit.doc, 13, function() {
				self.sync();
				document.forms['inputForm'].submit();
			});
		}
	});
});

		
</script>

<div class="body">
		<div class="inputBar">
			<h1><span class="icon">&nbsp;</span>课题管理</h1>
		</div>
		<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
			<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
				<ul></ul>
			</div>
		</div>	
		
		<form id="inputForm" name="inputForm" class="validate" action="<#if topicId??>${web_base}/go/topic!edit.htm<#else>${web_base}/go/topic!save.htm</#if>" method="post" enctype="multipart/form-data">
		<input type="hidden" name="topicInfo.topicId" class="formText" value="${(topicInfo.topicId)!}" />
		<input type="hidden" name="topicInfo.topicContentPathUrl" class="formText {required: true}" value="${(topicInfo.topicContentPathUrl)!}" />
			<table class="inputTable tabContent">
				<tr>
					<th>
						课题名称：
					</th>
					<td>
						<input type="text"  name="topicInfo.topicName" class="formText {required: true}" value="${(topicInfo.topicName)!}" />
						<label id="labelUrl" class="requireField">*</label>
					</td>
				</tr>
				<tr>
					<th>
						视频地址：
					</th>
					<td>
						<input type="text" id="url" name="topicInfo.videoPath" class="formText defaultInvalid url" value="${(topicInfo.videoPath)!}"/>
					</td>
				</tr>
				<tr>
					<th>
						课题日期：
					</th>
					<td>
						 <input type="text" id="startTime1" name="topicInfo.topicBeginTime"
                           onclick="WdatePicker({skin:'whyGreen',startDate:'%y',dateFmt:'yyyy-MM-dd'})"
                           value="${(topicInfo.topicBeginTime?string("yyyy-MM-dd"))!}" class="Wdate fixWidth" >
				         <span>--</span>
				         <input type="text" id="endTime1" name="topicInfo.topicEndTime"
                          onclick="WdatePicker({skin:'whyGreen',startDate:'%y',dateFmt:'yyyy-MM-dd'})"
                         value="${(topicInfo.topicEndTime?string("yyyy-MM-dd"))!}" class="Wdate fixWidth">
					</td>
				</tr>
				<tr>
					<th>
						课题预览图：
					</th>
					<td>
					<div style="float:left">
    				<input type="file" id="prePhoto" name="prePhoto" value="添加图片" onclick="showDiv('prePhoto','imgdiv1','imgShow1')"/>
						<div id="imgdiv1">
							<img id="imgShow1" width="160" height="100"  src="${(web_base + (topicInfo.prePhotoPath))!}"/>
							<span class="spanLink" onclick="clearImg('imgdiv1','imgShow1')" title="删除">[删除]</span>
						</div>
					</div>
					</td>
				</tr>
				<tr>
					<th>
						课题大图：
					</th>
					<td>
					<div style="float:left">
    				<input type="file" id="mainPhoto" name="mainPhoto" value="添加图片" onclick="showDiv('mainPhoto','imgdiv2','imgShow2')"/>
						<div id="imgdiv2">
							<img id="imgShow2" width="180" height="120" src="${(web_base + (topicInfo.mainPhotoPath))!}"/>
							<span class="spanLink" onclick="clearImg('imgdiv2','imgShow2')" title="删除">[删除]</span>
						</div>
					</div>
					</td>
				</tr>
				<tr>
					<th>课题简介：</th>
					<td>
						<textarea rows="8" cols="60" name="topicInfo.topicIntroduction" class="formText {}" >${(topicInfo.topicIntroduction)!}</textarea>
					</td>
				</tr>
				<tr>
					<th>课题内容：</th>
					<td>
						<textarea id="editor_id" name="content" style="width:800px;height:600px;">${(topicInfo.topicContentPath)!}</textarea>
						<strong><span style="color:#E53333;">图片支持格式：gif,jpg,jpeg,png,bmp</span></strong><br />
						<strong><span style="color:#E53333;"> flash支持格式：swf,flv</span></strong><br />
						<strong><span style="color:#E53333;"> media支持格式：swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb</span></strong><br />
						<strong><span style="color:#E53333;"> 文件支持格式：doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2</span></strong><br />
					</td>
				</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="提  交" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="取  消" hidefocus="true" />
			</div>
		</form>
	</div>
</body>
</@edit>